package com.example.administrator.yunniuusedcar.holder;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.common.ui.BaseAdapterRV;
import com.example.administrator.common.ui.BaseHolderRV;
import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.adapter.HomeCategoryAdapter;
import com.example.administrator.yunniuusedcar.model.mode_benn.Home;
import com.example.administrator.yunniuusedcar.model.mode_benn.HomeMenuBean;


import java.util.List;

/**
 * 随机汽车 网格 布局
 * Created by Administrator on 2017/12/15.
 */

public class Home02GridCarHolder extends BaseHolderRV<HomeMenuBean> {
    //    private ImageView ivIcon2;
//    private TextView tvTitle2;     // 菜单栏  汽车类型 网格
    private Home.Datamaunbeen Home_db;

    /**
     * 构造方法
     *
     * @param context     上下文对象
     * @param parent      指RecyclerView控件
     * @param adapter     适配器
     * @param layoutResId RecyclerView的一个item布局文件
     */
    private RecyclerView recyclerView02;
    private HomeCategoryAdapter homeCategoryAdapter;

    public Home02GridCarHolder(Context context, ViewGroup parent, BaseAdapterRV<HomeMenuBean> adapter) {
        super(context, parent, adapter, R.layout.item_recycleview);    //大容器    item_recycleview
    }

    @Override
    public void onFindViews(View itemView) {
        recyclerView02 = (RecyclerView) itemView.findViewById(R.id.recycler_view666);
    }

    @Override
    protected void onRefreshView(HomeMenuBean bean1, int position) {
        bean = (HomeMenuBean) bean1;   /// 强转
        List<HomeMenuBean.Data> data = bean.data;   //????

        // 2. 促销类型RecyclerView  网格
//        recyclerView02 = (RecyclerView) itemView.findViewById(R.id.recycler_view);
        recyclerView02.setLayoutManager(new GridLayoutManager(
                context, 2, RecyclerView.HORIZONTAL, false));
        //适配
        homeCategoryAdapter = new HomeCategoryAdapter(context, data);
        recyclerView02.setAdapter(homeCategoryAdapter);

//        tvTitle2.setText(bean.data.get(position).name);
//        Picasso.with(context).load(bean.data.get(position).logo).into(ivIcon2);
    }

}

